//
//  DetailCollectViewController.m
//  LOL_JewelBox
//
//  Created by dllo on 15/5/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "DetailCollectViewController.h"
#import "GMDCircleLoader.h"
#import <ShareSDK/ShareSDK.h>
@interface DetailCollectViewController ()
{
    UIWebView *webView;
}
@property(nonatomic, strong)NSMutableIndexSet *optionIndices;

@end

@implementation DetailCollectViewController

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.optionIndices = [NSMutableIndexSet indexSet];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSURL *url = [NSURL URLWithString:self.url];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, VIEWWIDTH, VIEWHEIGHT)];
    webView.backgroundColor = [UIColor whiteColor];
    //设置WebView的代理
    webView.delegate = self;
    //伸缩内容屏幕尺寸
    webView.scalesPageToFit = NO;
    //加载网络请求
    [webView loadRequest:request];
    [self.view addSubview:webView];
    //    [webView setOpaque:NO];
    [webView release];
    
    [GMDCircleLoader setOnView:self.view withTitle:@"Loading..." animated:YES];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"fenxiang"] style:UIBarButtonItemStylePlain target:self action:@selector(Click:)];
    
}


//deskAction抽屉效果

-(void)Click:(id)sender
{
    NSString *imagePath = [[NSBundle mainBundle]pathForResource:@"ShareSDK" ofType:@"png"];
    //构造分享内容
    id<ISSContent> publishContent = [ShareSDK content:self.url
                                       defaultContent:@"测试一下"
                                                image:[ShareSDK imageWithPath:imagePath]
                                                title:@"ShareSDK"
                                                  url:@"http://www.mob.com"
                                          description:@"这是一条测试信息"
                                            mediaType:SSPublishContentMediaTypeNews];
    //创建弹出菜单容器
    id<ISSContainer> container = [ShareSDK container];
    //        [container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
    
    //弹出分享菜单
    [ShareSDK showShareActionSheet:container
                         shareList:nil
                           content:publishContent
                     statusBarTips:YES
                       authOptions:nil
                      shareOptions:nil
                            result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
                                
                                if (state == SSResponseStateSuccess)
                                {
                                    NSLog(NSLocalizedString(@"TEXT_ShARE_SUC", @"分享成功"));
                                }
                                else if (state == SSResponseStateFail)
                                {
                                    NSLog(NSLocalizedString(@"TEXT_ShARE_FAI", @"分享失败,错误码:%d,错误描述:%@"), [error errorCode], [error errorDescription]);
                                }
                            }];
    
}
-(void)webViewDidStartLoad:(UIWebView *)webView
{
    
}

//WebView加载完毕的时候调用(请求完毕)

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [GMDCircleLoader hideFromView:self.view animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
